//
//  BIDRepairKindForOwnerViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/6/6.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDRepairKindForOwnerViewController.h"
#import "BIDCommonRepairListViewController.h"
#import "BIDOwnerPersonalRepairListViewController.h"

@interface BIDRepairKindForOwnerViewController ()
{
    NSArray *_dataSourceArr;
}
@end

@implementation BIDRepairKindForOwnerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"我的报修";
    _dataSourceArr = @[@{@"title":@"公共报修", @"className":@"BIDCommonRepairListViewController", @"isNeedXib":@0},
                       @{@"title":@"个人报修", @"className":@"BIDOwnerPersonalRepairListViewController", @"isNeedXib":@0}];
    _tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataSourceArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    static NSString *identifier = @"identifier";
    NSUInteger row = indexPath.row;
    cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    NSDictionary *dic = _dataSourceArr[row];
    cell.textLabel.text = dic[@"title"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSUInteger row = indexPath.row;
    if(row == 0)
    {
        //公共报修
        BIDCommonRepairListViewController *vc = [[BIDCommonRepairListViewController alloc] init];
        vc.userID = [AppDelegate getUserId];
        [self.navigationController pushViewController:vc animated:YES];
    }
    else
    {
        //个人报修
        BIDOwnerPersonalRepairListViewController *vc = [[BIDOwnerPersonalRepairListViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}


@end
